<?php

namespace app\admin\model;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use support\Model;

/**
 * 文件配置模型
 * @property int $id
 * @property string $name 配置名称
 * @property string $storage_type 存储类型:local=本地,oss=阿里云,cos=腾讯云,qiniu=七牛云,s3=亚马逊
 * @property string|null $config 存储类型特定配置(JSON格式)
 * @property int|null $single_limit 单个文件大小限制(字节)
 * @property int|null $total_limit 总文件大小限制(字节)
 * @property int|null $nums 文件数量限制
 * @property string|null $include 允许的文件类型
 * @property string|null $exclude 不允许的文件类型
 * @property string|null $remark 备注
 * @property int $status 状态:0=禁用,1=启用
 * @property int $sort 排序
 * @property string $create_time 创建时间
 * @property string $update_time 更新时间
 */
class FileUploadConfig extends Model
{
    /**
     * The table associated with the model.
     * @var string
     */
    protected $table = 'file_upload_config';
    /**
     * The primary key associated with the table.
     * @var string
     */
    protected $primaryKey = 'id';
    /**
     * Indicates if the model should be timestamped.
     * @var bool
     */
    public $timestamps = true;
    /**
     * The name of the "created at" column.
     * @var string|null
     */
    const CREATED_AT = 'create_time';
    /**
     * The name of the "updated at" column.
     * @var string|null
     */
    const UPDATED_AT = 'update_time';
    /**
     * The attributes that are mass assignable.
     * @var array
     */
    protected $fillable = [
        'name',
        'storage_type',
        'config',
        'single_limit',
        'total_limit',
        'nums',
        'include',
        'exclude',
        'remark',
        'status',
        'sort',
    ];
    /**
     * The attributes that should be cast to native types.
     * @var array
     */
    protected $casts = [
        'single_limit' => 'integer',
        'total_limit' => 'integer',
        'nums' => 'integer',
        'status' => 'integer',
        'sort' => 'integer',
        'config' => 'array', // 自动将JSON转换为数组
        'create_time' => 'datetime:Y-m-d H:i:s',
        'update_time' => 'datetime:Y-m-d H:i:s',
    ];
}